package com.pine.dao.pineframework.constants;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.pine.common.beans.enums.IntegerCodeBaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * <p>
 * 菜单表-菜单类型 枚举
 * </p>
 *
 * @author pine manage
 * @since 2024-08-12
 */
@AllArgsConstructor
@Getter
public enum MenuTypeEnum implements IntegerCodeBaseEnum {
    MENU(1, "菜单"),
    DIRECTORY(2, "目录"),
    EXTERNAL_LINK(3, "外链"),
    BUTTON(4, "按钮"),
    ;

    @EnumValue
    private final Integer code;
    private final String desc;

    public static MenuTypeEnum of(Integer code) {
        return Arrays.stream(MenuTypeEnum.values()).filter(menuTypeEnum -> Objects.equals(menuTypeEnum.code, code)).findAny().orElse(null);
    }
}
